<template>
  <div class="mod-config">
    <basic-container>
      <div class="boxsty zhiBiao">
        <div class="flex justifyContentSpaceBetween">
          <div class="tabletext">我经办的审批</div>
        </div>
        <div class="flex">
          <div class="mt20" style="height: 72px;">
            <el-form :inline="true" :model="dataForm" @keyup.enter.native="getDataList()" class="form-inline">
              <el-form-item label="审批名称">
                <el-input v-model="dataForm.ywTitle" clearable placeholder="审批名称" style="width: 260px;"></el-input>
              </el-form-item>
              <el-form-item>
                <el-button icon="el-icon-search" type="primary" class="marginLeft"
                           @click="getDataList(1)">检索
                </el-button>
              </el-form-item>
            </el-form>
          </div>
        </div>
        <el-table :data="dataList" v-loading="dataListLoading" stripe border class="avue-crud" height="480px">
          <el-table-column prop="" label="序号" :formatter="nShowIndex" width="70"></el-table-column>
          <el-table-column label="审批编号" prop="ywMainCode" align="center" min-width="120px"></el-table-column>
          <el-table-column label="审批名称" prop="ywTitle" header-align="center" align="left"
                           min-width="250px"></el-table-column>
          <el-table-column label="流程状态" prop="ywState" align="center" width="120px"></el-table-column>
          <el-table-column label="经办节点" prop="taskName" align="center" width="120px"></el-table-column>
          <el-table-column label="发起人" prop="fqRyName" align="center" width="120px"></el-table-column>
          <el-table-column label="接收时间" prop="ksTime" align="center" width="150px" show-overflow-tooltip>
            <template slot-scope="scope">{{ $moment(scope.row.ksTime).format("YYYY-MM-DD HH:mm") }}</template>
          </el-table-column>
          <el-table-column label="操作" align="center" min-width="100">
            <template slot-scope="scope">
              <el-button type="primary" plain @click="handleDialog(scope.row)">查看流程</el-button>
            </template>
          </el-table-column>
        </el-table>
        <div class="avue-crud__pagination">
          <el-pagination
            @size-change="sizeChangeHandle"
            @current-change="currentChangeHandle"
            :current-page="pageIndex"
            :page-sizes="[10, 20, 50, 100]"
            :page-size="pageSize"
            :total="totalPage"
            background
            layout="total, sizes, prev, pager, next, jumper">
          </el-pagination>
        </div>
      </div>
    </basic-container>
    <workflow ref="workflow" @refreshDataList="getDataList"></workflow>
  </div>
</template>

<script>
import {wdjbpage} from "@/api/workflow/wfywmain";
import workflow from '@/views/workflow/apply/index'

export default {
  name: "wdbd",
  data() {
    return {
      dataForm: {
        ywTitle: ''
      },
      dataList: [],
      pageIndex: 1,
      pageSize: 10,
      totalPage: 0,
      dataListLoading: false,
    }
  },
  components: {
    workflow
  },
  mounted() {
    this.getDataList();
  },
  methods: {
    getDataList(page) {
      if (page){
        this.pageIndex = page;
      }
      this.dataListLoading = true
      wdjbpage(Object.assign({
        current: this.pageIndex,
        size: this.pageSize
      }, this.dataForm)).then(response => {
        this.dataList = response.data.data.records
        this.totalPage = response.data.data.total
      })
      this.dataListLoading = false
    },
    formater(row, column, cellValue, index) {
      if (cellValue) {
        return this.$moment(cellValue).format("yyyy-MM-DD HH:mm");
      } else {
        return cellValue;
      }
    },
    nShowIndex(row, column, cellValue, index) {
      return index + 1 + this.pageSize * (this.pageIndex - 1);
    },
    // 每页数
    sizeChangeHandle(val) {
      this.pageSize = val
      this.pageIndex = 1
      this.getDataList()
    },
    // 当前页
    currentChangeHandle(val) {
      this.pageIndex = val
      this.getDataList()
    },
    handleDialog(r) {
      this.$refs.workflow.open(r.ywId)
    }
  }
}
</script>

<style scoped>

</style>
